-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] fix(Tabs): use tabIndex of -1 for non-active tabs #4951
Conversation
Set tabIndex -1 for non-active tabsPreviews: documentation | landing | table | modern colors demo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR preview works for me!
@@ -54,7 +54,7 @@ export class TabTitle extends AbstractPureComponent2<TabTitleProps> { | |||
id={generateTabTitleId(parentId, id)} | |||
onClick={disabled ? undefined : this.handleClick} | |||
role="tab" | |||
tabIndex={disabled ? undefined : 0} | |||
tabIndex={disabled ? undefined : selected ? 0 : -1} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tangentially related to this PR but I think if we set tabIndex={0}
when disabled here the element may not be visible to screen-readers
not 100% sure on that/not set up right now with a good way to test but it's been a working assumption of mine for awhile that disabled elements should remain in the tab order
if so it would possibly would be more appropriate to add to the wrapping div here but again I'm not sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this code will never set tabIndex={0}
when it's disabled, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, ^ was my understanding as well so i thought this was ok
@@ -54,7 +54,7 @@ export class TabTitle extends AbstractPureComponent2<TabTitleProps> { | |||
id={generateTabTitleId(parentId, id)} | |||
onClick={disabled ? undefined : this.handleClick} | |||
role="tab" | |||
tabIndex={disabled ? undefined : 0} | |||
tabIndex={disabled ? undefined : selected ? 0 : -1} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this code will never set tabIndex={0}
when it's disabled, though.
I learned recently that the recommendation (from https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Tab_Role#best_practices) for tab behavior is to only set
tabIndex={0}
for the active tab, and rely on left/right keyboard navigation for navigating the other tabs. This helps reduce the clutter on the screen for a user to have to tab through, while still allowing for navigation within the tablistThe blueprint tabs already support left/right key navigation, so it's mostly just the tabIndex that needed to be changed to respect the above
cc @evansjohnson